package com.ktjy.ktmall.dao.impl;

import com.ktjy.ktmall.dao.BaseDao;
import com.ktjy.ktmall.dao.BrandItemDao;
import com.ktjy.ktmall.entity.BrandItem;

import java.sql.SQLException;

/**
 * @auth wzy
 * @date 2024/10/31 10:56
 */
public class BrandItemDaoImpl extends BaseDao implements BrandItemDao {
    @Override
    public BrandItem findById(int id) {
        BrandItem b = null;
        String sql = "select * from t_brand where `enabled` = 0 and `id`=?";
        rs = super.executeQuery(sql, id);
        try {
            while (rs.next()) {
                b = new BrandItem(rs.getInt("id"), rs.getString("name"), rs.getString("logo_url"), rs.getInt("enabled"), rs.getString("create_time"), rs.getString("update_time"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            super.closeAll(rs, pstmt, conn);
        }
        return b;
    }
}
